<template>
  <div class="aside-container">
    <div class="expand" @click="isCollapse = !isCollapse">
      <i v-if="isCollapse" class="el-icon-s-fold"></i>
      <i v-else class="el-icon-s-unfold"></i>
    </div>
    <el-menu
      default-active="1-1"
      class="el-menu-vertical-demo el-menu-animation"
      :style="{ width: isCollapse ? '64px' : '200px' }"
      @open="handleOpen"
      @close="handleClose"
      @select="handleSelect"
      background-color="#304156"
      text-color="#fff"
      active-text-color="#196cff"
      :collapse="isCollapse"
    >
      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>导航一</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="1-1">
            <i class="el-icon-menu"></i>
            <span slot="title">选项1</span></el-menu-item
          >
          <el-menu-item index="1-2">
            <i class="el-icon-menu"></i>
            <span slot="title">选项2</span></el-menu-item
          >
        </el-menu-item-group>
      </el-submenu>
      <el-menu-item index="2">
        <i class="el-icon-menu"></i>
        <span slot="title">导航二</span>
      </el-menu-item>
      <el-menu-item index="3">
        <i class="el-icon-document"></i>
        <span slot="title">导航三</span>
      </el-menu-item>
      <el-menu-item index="4">
        <i class="el-icon-setting"></i>
        <span slot="title">导航四</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
@Component({
  name: "AsideIndex",
  components: {},
})
export default class AsideIndex extends Vue {
  public isCollapse = false;

  handleOpen(key: string, keyPath: string) {
    console.log(key, keyPath);
  }
  handleClose(key: string, keyPath: string) {
    console.log(key, keyPath);
  }
  handleSelect(index: string, indexPath: string) {
    console.log(index, indexPath);
  }
}
</script>

<style lang="scss" scoped>
.aside-container {
  display: flex;
  flex-direction: column;
  background-color: #304156;
  .expand {
    cursor: pointer;
    height: 30px;
    line-height: 30px;
    padding: 10px 0;
    text-align: center;
    i {
      color: white;
    }
  }
  .el-menu {
    /* width: 100%; */
    height: 100%;
    border-right: none;
    &.el-menu-animation {
      transition: all 0.3s ease-in-out;
    }
  }
}
</style>
